/*
 * This program is free software: you can redistribute it and/or modify it under the terms of the 
 * GNU Affero General Public License as published by the Free Software Foundation, either version 3 
 * of the License, or (at your option) any later version.
 * 
 * In accordance with Section 7(b) of the GNU Affero General Public License version 3, 
 * the Appropriate Legal Notices must display the following words on all interactive user interfaces: 
 * "Copyright (C) 2005-2011 SplendidCRM Software, Inc. All rights reserved."
 */

var sMENU_ACTIVE_MODULE = '';
var pnlMENU_ACTIVE_SUBMENU = null;

function TabMenuUI_Clear(sTabMenuCtl)
{
	try
	{
		var tblSixMenu = document.getElementById(sTabMenuCtl);
		if ( tblSixMenu.childNodes != null )
		{
			while ( tblSixMenu.childNodes.length > 0 )
			{
				tblSixMenu.removeChild(tblSixMenu.firstChild);
			}
		}
	}
	catch(e)
	{
		SplendidError.SystemAlert(e, 'TabMenuUI_Clear');
	}
}

function TabMenuUI_Clicked(sTabMenuCtl, sLayoutPanel, sActionsPanel, sMODULE_NAME)
{
	try
	{
		SplendidError.SystemMessage('Loading tab menu for ' + sMODULE_NAME);
		TabMenuUI_Load(sTabMenuCtl, sLayoutPanel, sActionsPanel, sMODULE_NAME, function(status, message)
		{
			var sGRID_NAME = sMODULE_NAME + '.ListView' + sPLATFORM_LAYOUT;
			SplendidError.SystemMessage('Loading ' + sGRID_NAME + '.');
			ListViewUI_Reset(sLayoutPanel, sMODULE_NAME);
			ListViewUI_Load(sLayoutPanel, sActionsPanel, sMODULE_NAME, sGRID_NAME, null, function(status, message)
			{
				if ( status == 1 )
				{
					SplendidError.SystemMessage('');
				}
				else
				{
					SplendidError.SystemMessage(' ' + message);
				}
			});
		});
	}
	catch(e)
	{
		SplendidError.SystemAlert(e, 'TabMenuUI_Clicked');
	}
}

function TabMenuUI_ActivateTab(sMODULE_NAME)
{
	if ( sMODULE_NAME != sMENU_ACTIVE_MODULE )
	{
		try
		{
			// 09/04/2011 Paul.  Deactivate the existing tab. 
			var tbl = document.getElementById('ctlTabMenu_tabMenuInner' + sMENU_ACTIVE_MODULE);
			if ( tbl != null )
			{
				tbl.rows[0].cells[0].className = 'otherTabLeft';
				tbl.rows[0].cells[1].className = 'otherTab';
				tbl.rows[0].cells[1].childNodes[0].className = 'otherTabLink';
				tbl.rows[0].cells[2].className = 'otherTabRight';
			}
			sMENU_ACTIVE_MODULE = sMODULE_NAME;
			// 09/04/2011 Paul.  Activate the new tab. 
			tbl = document.getElementById('ctlTabMenu_tabMenuInner' + sMENU_ACTIVE_MODULE);
			if ( tbl != null )
			{
				tbl.rows[0].cells[0].className = 'currentTabLeft';
				tbl.rows[0].cells[1].className = 'currentTab';
				tbl.rows[0].cells[1].childNodes[0].className = 'currentTabLink';
				tbl.rows[0].cells[2].className = 'currentTabRight';
			}
		}
		catch(e)
		{
			SplendidError.SystemAlert(e, 'TabMenuUI_ActivateTab');
		}
	}
}

function TabMenuUI_ActionsPopup(sTabMenuCtl, sLayoutPanel, sActionsPanel, sMODULE_NAME, sDISPLAY_NAME, ctlTabMenu_tabMenuInner, tdMenuInner)
{
	try
	{
		/*
		<div id="ctl00_pnlModuleActionsContacts" class="PanelHoverHidden" style="position: absolute; left: 412px; top: 151px; z-index: 1000; display: none; visibility: hidden; ">
			<table cellpadding="0" cellspacing="0" class="ModuleActionsShadingTable">
			<tbody>
				<tr>
					<td colspan="3" class="ModuleActionsShadingHorizontal"></td>
				</tr>
				<tr>
					<td class="ModuleActionsShadingVertical"></td>
					<td>
						<table cellpadding="0" cellspacing="0" class="ModuleActionsInnerTable">
						<tbody>
							<tr>
								<td class="ModuleActionsInnerCell">
									<span class="ModuleActionsInnerHeader" style="font-weight:bold;">Actions</span>
									<a class="ModuleActionsMenuItems" href="../Contacts/edit.aspx">Create Contact</a>
									<a class="ModuleActionsMenuItems" href="../Contacts/default.aspx">Contacts</a>
								</td>
							</tr>
						</tbody>
						</table>
					</td>
					<td class="ModuleActionsShadingVertical"></td>
				</tr>
				<tr>
					<td colspan="3" class="ModuleActionsShadingHorizontal"></td>
				</tr>
			</tbody>
			</table>
		</div>
		*/
		var pnlModuleActions = document.createElement('div');
		pnlModuleActions.id        = 'pnlModuleActions' + sMODULE_NAME;
		pnlModuleActions.className = 'PanelHoverHidden';
		tdMenuInner.appendChild(pnlModuleActions);
		var tblShading = document.createElement('table');
		tblShading.cellPadding = 0;
		tblShading.cellSpacing = 0;
		tblShading.className   = 'ModuleActionsShadingTable';
		pnlModuleActions.appendChild(tblShading);
		var tShading = document.createElement('tbody');
		tblShading.appendChild(tShading);
		
		// Shading Top
		var trShadingTop = document.createElement('tr');
		tShading.appendChild(trShadingTop);

		var tdShadingTop = document.createElement('td');
		tdShadingTop.colSpan   = 3;
		tdShadingTop.className = 'ModuleActionsShadingHorizontal';
		trShadingTop.appendChild(tdShadingTop);
		
		// Shading Center
		var trShadingCenter = document.createElement('tr');
		tShading.appendChild(trShadingCenter);
		var tdShadingLeft = document.createElement('td');
		tdShadingLeft.className = 'ModuleActionsShadingVertical';
		trShadingCenter.appendChild(tdShadingLeft);
		var tdShadingCenter = document.createElement('td');
		trShadingCenter.appendChild(tdShadingCenter);
		var tdShadingRight = document.createElement('td');
		tdShadingRight.className = 'ModuleActionsShadingVertical';
		trShadingCenter.appendChild(tdShadingRight);

		// Shading Bottom
		var trShadingBottom = document.createElement('tr');
		tShading.appendChild(trShadingBottom);
		var tdShadingBottom = document.createElement('td');
		tdShadingBottom.colSpan   = 3;
		tdShadingBottom.className = 'ModuleActionsShadingHorizontal';
		trShadingBottom.appendChild(tdShadingBottom);
		
		// Actions Inner Table
		var tblModuleActionsInner = document.createElement('table');
		tblModuleActionsInner.cellPadding = 0;
		tblModuleActionsInner.cellSpacing = 0;
		tblModuleActionsInner.className   = 'ModuleActionsInnerTable';
		tdShadingCenter.appendChild(tblModuleActionsInner);
		var tModuleActionsInner = document.createElement('tbody');
		tblModuleActionsInner.appendChild(tModuleActionsInner);

		var trModuleActionsInner = document.createElement('tr');
		tModuleActionsInner.appendChild(trModuleActionsInner);
		var tdModuleActionsInner = document.createElement('td');
		tdModuleActionsInner.className = 'ModuleActionsInnerCell';
		trModuleActionsInner.appendChild(tdModuleActionsInner);

		var spnActions = document.createElement('span');
		spnActions.className = 'ModuleActionsInnerHeader';
		spnActions.style.fontWeight = 'bold';
		spnActions.innerHTML        = L10n.Term('.LBL_ACTIONS');
		tdModuleActionsInner.appendChild(spnActions);
		
		var aCreate = document.createElement('a');
		aCreate.className = 'ModuleActionsMenuItems';
		aCreate.href      = 'javascript:EditViewUI_Load("' + sLayoutPanel + '", "' + sActionsPanel + '", "' + sMODULE_NAME + '", null, false);';
		aCreate.innerHTML = L10n.Term(sMODULE_NAME + '.LBL_NEW_FORM_TITLE');
		aCreate.onclick   = function()
		{
			pnlModuleActions.style.display    = 'none';
			pnlModuleActions.style.visibility = 'hidden';
		}
		tdModuleActionsInner.appendChild(aCreate);

		var aList = document.createElement('a');
		aList.className = 'ModuleActionsMenuItems';
		aList.href      = 'javascript:TabMenuUI_Clicked("' + sTabMenuCtl + '", "' + sLayoutPanel + '", "' + sActionsPanel + '", "' + sMODULE_NAME + '");';
		aList.innerHTML = L10n.Term(sDISPLAY_NAME);
		aList.onclick   = function()
		{
			pnlModuleActions.style.display    = 'none';
			pnlModuleActions.style.visibility = 'hidden';
		}
		tdModuleActionsInner.appendChild(aList);

		// http://www.quirksmode.org/dom/events/index.html
		ctlTabMenu_tabMenuInner.onmouseover = function(event)
		{
			if ( pnlMENU_ACTIVE_SUBMENU == pnlModuleActions )
				return;
			if ( pnlMENU_ACTIVE_SUBMENU != null )
			{
				pnlMENU_ACTIVE_SUBMENU.style.display    = 'none';
				pnlMENU_ACTIVE_SUBMENU.style.visibility = 'hidden';
				pnlMENU_ACTIVE_SUBMENU = null;
			}
			//SplendidError.SystemAlert(event, 'TabMenuUI_ActionsPopup ' + sMODULE_NAME);
			pnlModuleActions.style.display    = 'inline';
			pnlModuleActions.style.visibility = 'visible';
			pnlModuleActions.style.position   = 'absolute';
			var rect = ctlTabMenu_tabMenuInner.getBoundingClientRect();
			// 09/25/2011 Paul.  Internet Explorer does not support window.pageXOffset and window.pageYOffset. 
			if ( window.pageXOffset !== undefined )
				pnlModuleActions.style.left       = rect.left   + window.pageXOffset;
			else if ( document.body.scrollLeft !== undefined )
				pnlModuleActions.style.left       = rect.left   + document.body.scrollLeft;
			if ( window.pageYOffset !== undefined )
				pnlModuleActions.style.top        = rect.bottom + window.pageYOffset;
			else if ( document.body.scrollTop !== undefined )
				pnlModuleActions.style.top        = rect.bottom + document.body.scrollTop - 2;
			
			pnlMENU_ACTIVE_SUBMENU = pnlModuleActions;
			//SplendidError.SystemMessage('ctlTabMenu_tabMenuInner Left = ' + rect.left + ', Bottom = ' + rect.bottom );
		};
		// http://www.quirksmode.org/dom/w3c_cssom.html
		ctlTabMenu_tabMenuInner.onmouseout = function(event)
		{
			var rect = pnlModuleActions.getBoundingClientRect();
			//event.pageX;
			//event.pageY;
			// 09/25/2011 Paul.  IE does not support the event. 
			if ( event === undefined )
				event = window.event;
			//SplendidError.SystemMessage('event(' + event.clientX + ', ' + event.clientY + ') rect(' + rect.left + ', ' + rect.top + ', ' + rect.right + ', ' + rect.bottom + ') tabMenuInner');
			//SplendidError.SystemMessage('event.clientX < rect.left ' + (event.clientX < rect.left).toString() + ' || event.clientX > rect.right ' + (event.clientX > rect.right).toString() + ' || event.clientY < rect.top ' + (event.clientY < rect.top).toString() + ' || event.clientY > (rect.bottom + 2) ' + (event.clientY > (rect.bottom + 2)).toString() );
			if ( event.clientX < rect.left || event.clientX > rect.right || event.clientY < rect.top || event.clientY > (rect.bottom + 2) )
			{
				//SplendidError.SystemMessage('event(' + event.clientX + ', ' + event.clientY + ') rect(' + rect.left + ', ' + rect.top + ', ' + rect.right + ', ' + rect.bottom + ') tabMenuInner out');
				pnlModuleActions.style.display    = 'none';
				pnlModuleActions.style.visibility = 'hidden';
				pnlMENU_ACTIVE_SUBMENU = null;
			}
		};
		pnlModuleActions.onmouseover = function(event)
		{
		};
		pnlModuleActions.onmouseout = function(event)
		{
			var rect = pnlModuleActions.getBoundingClientRect();
			// 09/25/2011 Paul.  IE does not support the event. 
			if ( event === undefined )
				event = window.event;
			//SplendidError.SystemMessage('event(' + event.clientX + ', ' + event.clientY + ') rect(' + rect.left + ', ' + rect.top + ', ' + rect.right + ', ' + rect.bottom + ') ModuleActions');
			//SplendidError.SystemMessage('event.clientX < rect.left ' + (event.clientX < rect.left).toString() + ' || event.clientX > rect.right ' + (event.clientX > rect.right).toString() + ' || event.clientY < rect.top ' + (event.clientY < rect.top).toString() + ' || event.clientY > (rect.bottom + 2) ' + (event.clientY > (rect.bottom + 2)).toString() );
			if ( event.clientX < rect.left || event.clientX > rect.right || event.clientY < (rect.top - 2) || event.clientY > rect.bottom )
			{
				pnlModuleActions.style.display    = 'none';
				pnlModuleActions.style.visibility = 'hidden';
				pnlMENU_ACTIVE_SUBMENU = null;
				//SplendidError.SystemMessage('event(' + event.clientX + ', ' + event.clientY + ') rect(' + rect.left + ', ' + rect.top + ', ' + rect.right + ', ' + rect.bottom + ') ModuleActions out');
			}
		};
	}
	catch(e)
	{
		SplendidError.SystemAlert(e, 'TabMenuUI_ActionsPopup ' + sMODULE_NAME);
	}
}

function TabMenuUI_ActionsBar(sTabMenuCtl, sLayoutPanel, sActionsPanel, sMODULE_NAME, sDISPLAY_NAME, tdActions)
{
	try
	{
		/*
		<div id=ctl00_cntLastViewed_ctlActions_divShortcuts class=lastView width="100%">
			<b>Actions:&nbsp;&nbsp;</b> 
			<nobr>
				<a class=lastViewLink title="Create User" href="edit.aspx">
					<img border=0 align=absMiddle src="/SplendidCRM6/App_Themes/Sugar/images/CreateUsers.gif" width=16 height=16>
					 &nbsp;Create User
				</a>&nbsp; 
			</nobr>
			<nobr>
				<a class=lastViewLink title=Users href="default.aspx">
					<img border=0 align=absMiddle src="/SplendidCRM6/App_Themes/Sugar/images/Users.gif" width=16 height=16>
					 &nbsp;Users
				</a>&nbsp; 
			</nobr>
		</div>
		*/
		var pnlModuleActions = document.createElement('div');
		pnlModuleActions.id        = 'pnlModuleActions' + sMODULE_NAME;
		pnlModuleActions.className = 'lastView';
		pnlModuleActions.width     = '100%';
		tdActions.appendChild(pnlModuleActions);
		
		var lblActions = document.createElement('b');
		lblActions.innerHTML = L10n.Term('.LBL_ACTIONS') + '&nbsp;&nbsp;'
		pnlModuleActions.appendChild(lblActions);
		
		var nobrCreate = document.createElement('nobr');
		pnlModuleActions.appendChild(nobrCreate);
		var aCreate = document.createElement('a');
		aCreate.className = 'lastViewLink';
		aCreate.href      = 'javascript:EditViewUI_Load("' + sLayoutPanel + '", "' + sActionsPanel + '", "' + sMODULE_NAME + '", null, false);';
		aCreate.title     = L10n.Term(sMODULE_NAME + '.LBL_NEW_FORM_TITLE');
		nobrCreate.appendChild(aCreate);
		
		/*
		var imgCreate = document.createElement('img');
		// 10/15/2011 Paul.  Must append image before setting src. 
		aCreate.appendChild(imgCreate);
		imgCreate.align       = 'absmiddle';
		imgCreate.height      = 16;
		imgCreate.width       = 16;
		imgCreate.borderWidth = 0;
		imgCreate.src         = sIMAGE_SERVER + 'App_Themes/Six/images/Create' + sMODULE_NAME + '.gif';
		imgCreate.style.paddingRight = 5;
		*/
		var txtCreate = document.createTextNode(L10n.Term(sMODULE_NAME + '.LBL_NEW_FORM_TITLE'));
		aCreate.appendChild(txtCreate);
		
		var nobrList = document.createElement('nobr');
		pnlModuleActions.appendChild(nobrList);
		var aList = document.createElement('a');
		aList.className = 'lastViewLink';
		aList.href      = 'javascript:TabMenuUI_Clicked("' + sTabMenuCtl + '", "' + sLayoutPanel + '", "' + sActionsPanel + '", "' + sMODULE_NAME + '");';
		aList.title     = L10n.Term(sDISPLAY_NAME);
		nobrList.appendChild(aList);
		
		/*
		var imgList = document.createElement('img');
		// 10/15/2011 Paul.  Must append image before setting src. 
		aList.appendChild(imgList);
		imgList.align       = 'absmiddle';
		imgList.height      = 16;
		imgList.width       = 16;
		imgList.borderWidth = 0;
		imgList.src         = sIMAGE_SERVER + 'App_Themes/Six/images/' + sMODULE_NAME + '.gif';
		imgList.style.paddingRight = 5;
		*/
		var txtList = document.createTextNode(L10n.Term(sDISPLAY_NAME));
		aList.appendChild(txtList);
	}
	catch(e)
	{
		SplendidError.SystemAlert(e, 'TabMenuUI_ActionsBar ' + sMODULE_NAME);
	}
}

function TabMenuUI_CreateTab(sTabMenuCtl, sLayoutPanel, sActionsPanel, sMODULE_NAME, sDISPLAY_NAME)
{
	var tbl = document.createElement('table');
	try
	{
		tbl.id          = 'ctlTabMenu_tabMenuInner' + sMODULE_NAME;
		tbl.className   = 'tabFrame';
		tbl.cellSpacing = 0;
		tbl.cellPadding = 0;
		tbl.height      = 25;

		var tbody = document.createElement('tbody');
		tbl.appendChild(tbody);
		var tr = document.createElement('tr');
		tbody.appendChild(tr);

		var td = document.createElement('td');
		tr.appendChild(td);
		if ( sMENU_ACTIVE_MODULE == sMODULE_NAME )
			td.className = 'currentTabLeft';
		else
			td.className = 'otherTabLeft';

		var img = document.createElement('img');
		td.appendChild(img);
		img.src         = sIMAGE_SERVER + 'App_Themes/Six/images/blank.gif';
		img.align       = 'absmiddle';
		img.width       = 5;
		img.height      = 25;
		img.borderWidth = 0;

		td = document.createElement('td');
		tr.appendChild(td);
		if ( sMENU_ACTIVE_MODULE == sMODULE_NAME )
			td.className = 'currentTab';
		else
			td.className = 'otherTab';

		td.setAttribute('nowrap', '1');
		var a = document.createElement('a');
		// 10/16/2011 Paul.  Give the link a name so that we can find it and simulate a click. 
		a.id = sTabMenuCtl + '_' + sMODULE_NAME;
		td.appendChild(a);
		if ( sMENU_ACTIVE_MODULE == sMODULE_NAME )
			a.className = 'currentTabLink';
		else
			a.className = 'otherTabLink';
		//a.href      = 'javascript:TabMenuUI_Clicked("' + sTabMenuCtl + '", "' + sLayoutPanel + '", "' + sActionsPanel + '", "' + sMODULE_NAME + '");';
		a.href = 'javascript:void(0);';
		a.onclick = function()
		{
			TabMenuUI_Clicked(sTabMenuCtl, sLayoutPanel, sActionsPanel, sMODULE_NAME);
		};
		
		a.innerHTML = '<nobr>' + L10n.Term(sDISPLAY_NAME) + '</nobr>';

		td = document.createElement('td');
		tr.appendChild(td);
		if ( sMENU_ACTIVE_MODULE == sMODULE_NAME )
			td.className = 'currentTabRight';
		else
			td.className = 'otherTabRight';

		img = document.createElement('img');
		td.appendChild(img);
		img.align       = 'absmiddle';
		img.width       = 5;
		img.height      = 25;
		img.borderWidth = 0;
		img.src         = sIMAGE_SERVER + 'App_Themes/Six/images/blank.gif';
		/*
		<td valign="bottom">
			<table id="ctlTabMenu_tabMenuInnerAccounts" class="tabFrame" cellspacing="0" cellpadding="0" height="25">
				<tr>
					<td class="currentTabLeft"><img src="App_Themes/Six/images/blank.gif" align="absmiddle" style="border-width:0px;height:25px;width:5px;" /></td>
					<td class="currentTab" nowrap="1"><a class="currentTabLink" href="javascript:void(0);">Accounts</a></td>
					<td class="currentTabRight"><img src="App_Themes/Six/images/blank.gif" align="absmiddle" style="border-width:0px;height:25px;width:5px;" /></td>
				</tr>
			</table>
		</td>
		*/
	}
	catch(e)
	{
		SplendidError.SystemAlert(e, 'TabMenuUI_CreateTab');
	}
	return tbl;
}

function DetailViewRelationshipExists(arr, sMODULE_NAME)
{
	for ( var i in arr )
	{
		if ( arr[i].MODULE_NAME == sMODULE_NAME )
		{
			return true;
		}
	}
	return false;
}

function TabMenuUI_Load(sTabMenuCtl, sLayoutPanel, sActionsPanel, sMODULE_NAME, callback)
{
	try
	{
		sMENU_ACTIVE_MODULE = sMODULE_NAME;
		var bgPage = chrome.extension.getBackgroundPage();
		bgPage.Terminology_LoadModule(sMODULE_NAME, function(status, message)
		{
			if ( status == 0 || status == 1 )
			{
				var sDETAIL_NAME = 'TabMenu' + sPLATFORM_LAYOUT;
				bgPage.DetailViewRelationships_LoadLayout(sDETAIL_NAME, function(status, message)
				{
					if ( status == 0 || status == 1 )
					{
						// 10/03/2011 Paul.  DetailViewRelationships_LoadLayout returns the layout. 
						var arrDetailViewRelationship = message;
						bgPage.TabMenu_Load(function(status, message)
						{
							if ( status == 0 || status == 1 )
							{
								//alert(dumpObj(message, 'd'));
								try
								{
									var result = message;
									//alert(dumpObj(result, 'result'));
									TabMenuUI_Clear(sTabMenuCtl)
									
									// 10/15/2011 Paul.  sTabMenuCtl is a div tag now so that we can do more with the panel. 
									var ctlTabMenu = document.getElementById(sTabMenuCtl);
									// <table id="ctlTabMenu_tblSixMenu" class="tabFrame" cellspacing="0" cellpadding="0" bgcolor="#ffd14e"></table>
									var tblSixMenu = document.createElement('table');
									tblSixMenu.id                    = sTabMenuCtl + '_tblSixMenu';
									tblSixMenu.className             = 'tabFrame';
									tblSixMenu.cellSpacing           = 0;
									tblSixMenu.cellPadding           = 0;
									tblSixMenu.style.backgroundColor = '#ffd14e';
									ctlTabMenu.appendChild(tblSixMenu);
									
									var tbody = document.createElement('tbody');
									tblSixMenu.appendChild(tbody);
									// <td style="padding-left:14px;" class="otherTabRight">&nbsp;</td>
									var tr = document.createElement('tr');
									tbody.appendChild(tr);
									var td = document.createElement('td');
									tr.appendChild(td);
									td.className         = 'otherTabRight';
									td.style.paddingLeft = 14;
									td.innerHTML = '&nbsp;';
									
									//var arrDetailViewRelationship = bgPage.SplendidCache.DetailViewRelationships(sDETAIL_NAME);
									//alert(dumpObj(arrDetailViewRelationship, 'arrDetailViewRelationship'));
									for ( var i = 0; i < result.length; i++ )
									{
										var sMODULE_NAME = result[i].MODULE_NAME;
										if ( DetailViewRelationshipExists(arrDetailViewRelationship, sMODULE_NAME) )
										{
											var sDISPLAY_NAME  = result[i].DISPLAY_NAME ;
											var sRELATIVE_PATH = result[i].RELATIVE_PATH;
											td = document.createElement('td');
											tr.appendChild(td);
											td.vAlign = 'bottom';
											var tabMenuInner = TabMenuUI_CreateTab(sTabMenuCtl, sLayoutPanel, sActionsPanel, sMODULE_NAME, sDISPLAY_NAME);
											td.appendChild(tabMenuInner);
											
											var sUSER_AGENT = navigator.userAgent;
											// 10/20/2011 Paul.  Nook with Android SD uses WIN. 
											if ( sUSER_AGENT == 'WIN' || sUSER_AGENT.indexOf('Android') > 0 || sUSER_AGENT.indexOf('iPad') > 0 || sUSER_AGENT.indexOf('iPhone') > 0 )
											{
												if ( sMENU_ACTIVE_MODULE == sMODULE_NAME )
												{
													var trActions = document.createElement('tr');
													tbody.appendChild(trActions);
													var tdActions = document.createElement('td');
													trActions.appendChild(tdActions);
													TabMenuUI_ActionsBar(sTabMenuCtl, sLayoutPanel, sActionsPanel, sMODULE_NAME, sDISPLAY_NAME, ctlTabMenu);
												}
											}
											else
											{
												TabMenuUI_ActionsPopup(sTabMenuCtl, sLayoutPanel, sActionsPanel, sMODULE_NAME, sDISPLAY_NAME, tabMenuInner, td);
											}
										}
									}
									// <td width="100%" class="tabRow"><img src="App_Themes/Six/images/blank.gif" align="absmiddle" style="border-width:0px;height:1px;width:1px;" /></td>
									td = document.createElement('td');
									tr.appendChild(td);
									td.className = 'tabRow';
									td.width     = '100%';
									var img = document.createElement('img');
									td.appendChild(img);
									img.align       = 'absmiddle';
									img.width       = 1;
									img.height      = 1;
									img.borderWidth = 0;
									img.src         = sIMAGE_SERVER + 'App_Themes/Six/images/blank.gif';
									
									callback(1, null);
								}
								catch(e)
								{
									callback(-1, SplendidError.FormatError(e, 'TabMenuUI_Load'));
								}
							}
							else
							{
								callback(status, message);
							}
						});
					}
					else
					{
						callback(status, message);
					}
				});
			}
			else
			{
				SplendidError.SystemMessage(message);
			}
		});
	}
	catch(e)
	{
		callback(-1, SplendidError.FormatError(e, 'TabMenuUI_Load'));
	}
}


